package com.example.nna.util;

import java.security.MessageDigest;
import java.util.Map;

public class UserInfo {
	static String mUser;
	static String mPass;
	static Map<String, String> cookies ;
	static String UserId;
	static boolean isLogin;
	private String securityToken = "guest";

	public UserInfo(){
	}
	public void cookies(Map<String, String> m_cookies){
		cookies = m_cookies;
	}
	public Map<String, String> cookies(){
		return cookies;
	}
	public UserInfo(String muser,String mpass){
		mUser = muser;
		mPass = mpass;
	}
	public void setLogin(boolean bool){
		isLogin = bool;
	}
	public boolean isLogin(){
		return isLogin;
	}
	public void setUserId(String mUserId){
		UserId = mUserId;
	}
	public String UserId(){
		return UserId;
	}
	public void setToken(String securityToken){
		this.securityToken = securityToken;
	}
	public String Token(){
		return securityToken;
	}
	public String User(){
		return mUser;
	}
	public String Pass(){
		return mPass;
	}
	public void add(String muser,String mpass){
		mUser = muser;
		mPass = mpass;
	}
	public String md5Pass(){
		return md5(mPass);
	}
	private String md5(String md5){
		StringBuffer sb = new StringBuffer();
		try {
	        MessageDigest md = MessageDigest.getInstance("MD5");
	        byte[] array = md.digest(md5.getBytes());
	        System.out.println(array);
	        for (int i = 0; i < array.length; ++i) {
	          sb.append(Integer.toHexString((array[i] & 0xFF) | 0x100).substring(1,3));
	        }
		} catch (java.security.NoSuchAlgorithmException e) {
	   
		}
		return sb.toString();
	}
}
